package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.TrainingCredits;
import com.ruoyi.personnel.mapper.TrainingCreditsMapper;
import com.ruoyi.personnel.service.ITrainingCreditsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 培训学分记录Service业务层处理
 *
 * @author ruoyi
 * @date 2021-02-26
 */
@Service
public class TrainingCreditsServiceImpl extends ServiceImpl<TrainingCreditsMapper, TrainingCredits> implements ITrainingCreditsService {

    @Override
    public List<TrainingCredits> queryList(TrainingCredits trainingCredits) {
        LambdaQueryWrapper<TrainingCredits> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(trainingCredits.getName())){
            lqw.like(TrainingCredits::getName ,trainingCredits.getName());
        }
        if (StringUtils.isNotBlank(trainingCredits.getJobNumber())){
            lqw.eq(TrainingCredits::getJobNumber ,trainingCredits.getJobNumber());
        }
        if (StringUtils.isNotBlank(trainingCredits.getPersonnelId())){
            lqw.eq(TrainingCredits::getPersonnelId ,trainingCredits.getPersonnelId());
        }
        if (StringUtils.isNotBlank(trainingCredits.getTrainingName())){
            lqw.like(TrainingCredits::getTrainingName ,trainingCredits.getTrainingName());
        }
        if (StringUtils.isNotBlank(trainingCredits.getTrainingLocation())){
            lqw.eq(TrainingCredits::getTrainingLocation ,trainingCredits.getTrainingLocation());
        }
        if (StringUtils.isNotBlank(trainingCredits.getTrainingTime())){
            lqw.eq(TrainingCredits::getTrainingTime ,trainingCredits.getTrainingTime());
        }
        if (trainingCredits.getCredit() != null){
            lqw.eq(TrainingCredits::getCredit ,trainingCredits.getCredit());
        }
        if (StringUtils.isNotBlank(trainingCredits.getTrainingOffice())){
            lqw.eq(TrainingCredits::getTrainingOffice ,trainingCredits.getTrainingOffice());
        }
        if (StringUtils.isNotBlank(trainingCredits.getTrainingLevel())){
            lqw.eq(TrainingCredits::getTrainingLevel ,trainingCredits.getTrainingLevel());
        }
        if (StringUtils.isNotBlank(trainingCredits.getStatus())){
            lqw.eq(TrainingCredits::getStatus ,trainingCredits.getStatus());
        }
        return this.list(lqw);
    }
}
